home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / OutOfContextMenus / Source / CVBlankBehavior.cp < prev    next >
Encoding:
Text File  |  1999-06-25  |  2.2 KB  |  88 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    CVBlankBehavior.cp                 ©1999 Eric Traut
  3. // ===========================================================================
  4.  
  5. #include "CVBlankBehavior.h"
  6. #include "CShadowWindow.h"
  7.  
  8.  
  9. // ---------------------------------------------------------------------------
  10. //        • CVBlankBehavior
  11. // ---------------------------------------------------------------------------
  12.  
  13. CVBlankBehavior::CVBlankBehavior(
  14.     CShadowWindow &        inShadowWindow)
  15.     :    COffscreenBehavior(inShadowWindow, true, true)
  16. {
  17.     mLastBlitTicks = ::TickCount();
  18.     mVOffset = 0;
  19. }
  20.  
  21.  
  22. // ---------------------------------------------------------------------------
  23. //        • SyncWithShadowWindow
  24. // ---------------------------------------------------------------------------
  25.  
  26. Boolean
  27. CVBlankBehavior::SyncWithShadowWindow(void)
  28. {
  29.     Boolean            didSync;
  30.     
  31.     didSync = COffscreenBehavior::SyncWithShadowWindow();
  32.     
  33.     if (didSync)
  34.     {
  35.         // Recalculate our blur rect
  36.         CWindowRecord *        macWindow = mShadowWindow.GetMacWindow();
  37.         mInvertRect = macWindow->port.portRect;
  38.         
  39.         mInvertRect.right -= 15;
  40.         mInvertRect.bottom -= 15;
  41.         mInvertRect.top += 21;
  42.     }
  43.     
  44.     return didSync;
  45. }
  46.  
  47.         
  48. // ---------------------------------------------------------------------------
  49. //        • RenderToGWorld
  50. // ---------------------------------------------------------------------------
  51.  
  52. Boolean
  53. CVBlankBehavior::RenderToGWorld(
  54.     StGWorldLocker &        inBackingLocker,
  55.     StGWorldLocker &        inRenderingLocker)
  56. {
  57.     // Split the blit into two halves.
  58.     
  59.     Rect        destRect;
  60.  
  61.     destRect = mGWorldRect;
  62.     ::OffsetRect(&destRect, 0, mVOffset);
  63.     ::CopyBits(    reinterpret_cast<BitMap *>(*inBackingLocker.GetPixMap()),
  64.                 reinterpret_cast<BitMap *>(*inRenderingLocker.GetPixMap()),
  65.                 &mGWorldRect,
  66.                 &destRect,
  67.                 srcCopy,
  68.                 NULL);
  69.  
  70.     destRect = mGWorldRect;
  71.     ::OffsetRect(&destRect, 0, mVOffset - (mGWorldRect.bottom - mGWorldRect.top));
  72.     ::CopyBits(    reinterpret_cast<BitMap *>(*inBackingLocker.GetPixMap()),
  73.                 reinterpret_cast<BitMap *>(*inRenderingLocker.GetPixMap()),
  74.                 &mGWorldRect,
  75.                 &destRect,
  76.                 srcCopy,
  77.                 NULL);
  78.  
  79.     mVOffset += 2;
  80.     
  81.     if (mVOffset > (mGWorldRect.bottom - mGWorldRect.top))
  82.         mVOffset = 0;
  83.     
  84.     return true;
  85. }
  86.  
  87.  
  88.